{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "c1f5b50e",
   "metadata": {},
   "source": [
    "# 元组（tuple）\n",
    "\n",
    "> 1.与list几乎完全一样的序列数据  \n",
    "> 2.与list不同的是： **不可变**（因为不可变，所以几乎没有方法）  \n",
    "> 3.元组的形式：（1,2,34,5） 对比 元组（） 列表[ ]  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "5e3747f2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('10001', '10002', '10003', '10001') <class 'tuple'>\n"
     ]
    }
   ],
   "source": [
    "stu_id = \"10001\",\"10002\",\"10003\",\"10001\"\n",
    "print(stu_id,type(stu_id))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "7b1d8418",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stu_id.count(\"10001\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "15cc160d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stu_id.index(\"10002\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "1020c8b5",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "05cba0dd",
   "metadata": {},
   "source": [
    "# 字典\n",
    "\n",
    "> 1.创建字典的三种常见放大\n",
    ">> 1.直接按照字典的格式创建： {key1:value1,key2:value2...}\n",
    ">> 2.dict（）函数来创建字典 ： dict(key1=value1,key2=value2,...)\n",
    ">> 3.字典数据增加的方式： 新建空字典 dict_name = {} ,dict_name[key1] = value1 ..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "6a2eae81",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stu_10001': 'Alex', 'stu_10002': 'Jack', 'stu_10003': 'Mary'}"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 1.直接按照字典的格式创建： {key1:value1,key2:value2...}\n",
    "stu_info = {\"stu_10001\":\"Alex\",\n",
    "            \"stu_10002\":\"Jack\",\n",
    "            \"stu_10003\":\"Mary\"}\n",
    "stu_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "c975e255",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stu_10001': 'Alex', 'stu_10002': 'Jack', 'stu_10003': 'Mary'}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 2.dict（）函数来创建字典 ： dict(key1=value1,key2=value2,...)\n",
    "stu_info_2 = dict(stu_10001=\"Alex\",\n",
    "            stu_10002=\"Jack\",\n",
    "            stu_10003=\"Mary\")\n",
    "stu_info_2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "ec36ee1f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stu_10001': 'Alex', 'stu_10002': 'Jack', 'stu_10003': 'Mary'}"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 3.字典数据增加的方式： 新建空字典 dict_name = {} ,dict_name[key1] = value1 ...\n",
    "stu_info_3 = {}\n",
    "stu_info_3[\"stu_10001\"] = \"Alex\"\n",
    "stu_info_3[\"stu_10002\"] = \"Jack\"\n",
    "stu_info_3[\"stu_10003\"] = \"Mary\"\n",
    "stu_info_3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "9231a7ef",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (<ipython-input-14-b0a2dfbc81d1>, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-14-b0a2dfbc81d1>\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m    stu_info_3.\u001b[0m\n\u001b[1;37m               ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "stu_info_3.\n",
    "字典方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "922438ca",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "hide_input": false,
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
